﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace AgCIMProductFuncLib
{
    /// <summary>
    /// 线要素数据模型
    /// </summary>
    public class LineFeature
    {
        /// <summary>
        /// 几何类型（固定为"PolyLine"）
        /// </summary>
        [JsonIgnore] 
        public string Type { get; set; } = "PolyLine";

        /// <summary>
        /// 子线段列表（每个子线段是一组有序坐标点）
        /// </summary>
        public List<List<Coordinate>> Parts { get; set; }

        /// <summary>
        /// 属性数据（键值对）
        /// </summary>
        public Dictionary<string, object> Attributes { get; set; }

        public string AppID
        {
            get
            {
                if (Attributes.ContainsKey("PID"))
                {
                    return Attributes["PID"]+"";
                }
                return "";
            }
        }

        internal void ScaleToWidth(double dx, double minx, double maxY)
        {
            for (int i = 0; i < Parts.Count; i++)
            {
                for(var j=0;j< Parts[i].Count; j++)
                {
                    Parts[i][j].ScaleToWidth(minx, maxY, dx);
                }
            }
        }
    }
}
